import {
    userProfilesApi
} from "@/request/api";
export default {
    namespaced: true,
    state: {
        userInfo: {
            nickName: '昵称',
            coin: '0',
            headImg: require('../../assets/img/service.848ec511.png')
        },
        cartTotal: 9
    },
    mutations: {
        changeUserInfo(state, payload) {
            state.userInfo = payload.userInfo;
            state.cartTotal = payload.cartTotal;
        },
        changeReductionUserInfo(state, payload) {
            state.userInfo = {
                    nickName: '昵称',
                    coin: '0',
                    headImg: require('../../assets/img/service.848ec511.png')
                },
                state.cartTotal = 0
        }
    },
    actions: {
        async asyncChangeUserInfo({
            commit
        }) {
            let user = await userProfilesApi()
            // console.log('asyncChangeUserInfo', user);
            commit('changeUserInfo', user.data)
        }
    }
}